package com.example.nio.filechannel;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author panghu
 * @version 1.0.0
 * @createTime 2023年08月06日 14:57:00
 * @Description
 */
public class Demo01 {

    public static void main(String[] args) throws IOException {
        try(FileOutputStream out = new FileOutputStream("test.txt");
            FileInputStream in = new FileInputStream("test.txt")){
            String data = "伞兵一号卢本伟准备就绪！";
            out.write(data.getBytes());   //向文件的输出流中写入数据，也就是把数据写到文件中
            out.flush();

            byte[] bytes = new byte[in.available()];
            in.read(bytes);    //从文件的输入流中读取文件的信息
            System.out.println(new String(bytes));
        }
    }

}
